package com.fy.market.activity.service.rule.chain.chainFactory;

import com.fy.market.activity.service.rule.chain.IActionChain;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @author fwq
 * @description 活动规则过滤责任链组装工厂
 * @date 2025-10-11 13:28
 */
@Slf4j
@Component
public class ActionChainFactory {

    public final Map<String, IActionChain> actionChainMap;

    public ActionChainFactory(Map<String, IActionChain> actionChainMap) {
        this.actionChainMap = actionChainMap;
    }

    // 组装活动规则过滤责任链
    public IActionChain assembleActionChain() {
        IActionChain actionChain = actionChainMap.get("action_base_filter");
        actionChain.appendNext(actionChainMap.get("action_stock_filter"));

        log.info("责任链组装成功,完整链条:{}",actionChain.getChainInfo());
        log.info("责任链组装成功,当前节点:{}",actionChain.getNodeName());
        return actionChain;
    }
}
